/* $Id: array.h 16 2006-12-16 15:37:49Z judas $ */

#ifndef NIH_ARRAY_H
#define NIH_ARRAY_H 1

#include <nih/cdefs.h>

BEGIN_C_DECLS

#include <nih/types.h>

#include <stdlib.h>
#include <sys/types.h>

struct nih_array {
	void **values;
	size_t len;
	void *udata;
};

extern struct nih_array *nih_acreate(size_t len);

extern int nih_aresize(struct nih_array *array, size_t newlen);

extern int nih_aset(struct nih_array *array, size_t n, const void *value);

extern int nih_aget(const struct nih_array *array, size_t n, void **value);

extern int nih_adestroy_deep(struct nih_array *array, nih_free_fnc *free_fnc);

extern inline int nih_adestroy(struct nih_array *array)
{
        return nih_adestroy_deep(array, NULL);
}

END_C_DECLS

#endif /* NIH_ARRAY_H */

